package ds.factcom.domain.client;


/**
 * 
 * @author Javier De Luca, Maximiliano Herrera, Matias Samblancat
 * 
 */
public class Document {

	private String number;
	private DocumentType documentType;
	
	public Document(String type, String documentNumber) {
		this.number = documentNumber;
		this.selectDocumentType(type);
	}
	
	/**
	 * Selecciona que tipo de documento es el que se selecciono.
	 * @param type tipo de valor que es ingresado por teclado.
	 */
	private void selectDocumentType(String type){
		if(type.equalsIgnoreCase(DocumentType.CUIT.getValue())){
			this.documentType = DocumentType.CUIT;
		}else if (type.equalsIgnoreCase(DocumentType.DU.getValue())){
			this.documentType = DocumentType.DU;
		}else if (type.equalsIgnoreCase(DocumentType.DNI.getValue())){
			this.documentType = DocumentType.DNI;
		}
	}

	public void setDocumentType(DocumentType documentType) {
		this.documentType = documentType;
	}
	
	public DocumentType getDocumentType() {
		return documentType;
	}
	
	public void setNumber(String number) {
		this.number = number;
	}
	
	public String getNumber() {
		return number;
	}
	
	@Override
	public boolean equals(Object obj) {
		Document document = (Document)obj;
		return document.getNumber().equals(this.number)&&
		document.getDocumentType().getValue().equalsIgnoreCase(this.documentType.getValue());
	}
}
